home *** CD-ROM | disk | FTP | other *** search
/ Collection of Tools & Utilities / Collection of Tools and Utilities.iso / tex / nghelp.zip / NGCL.PAS < prev    next >
Pascal/Delphi Source File  |  1992-11-06  |  29KB  |  1,158 lines

  1. {$A+,B-,E+,F-,I+,N-,O-,R-,V-}
  2. {$DEFINE DEBUG}
  3. {$IFDEF DEBUG} {$D+,L+,S+} {$ELSE} {$D-,L-,S-} {$ENDIF}
  4. Unit NGCL;
  5.  
  6. Interface
  7.  
  8. Uses YNSystem,YNDos,YNCrt,FastScr,StrInt,Invoer,Help_Var,Window,NG;
  9.  
  10. Procedure InitVars_NG;
  11. Procedure ChangeWindowSize(Big : Boolean);
  12. Procedure LookUp(Beep : Boolean);
  13.  
  14. Procedure LoadNGGuide;
  15. Procedure ProccessKeyStrokeNG; {Proccess a key stroke}
  16. Procedure BuildScreenNG; {Build ng screen from nothing}
  17.  
  18. Procedure StartNG;
  19.  
  20.  
  21. Implementation
  22.  
  23.  
  24. Const MaxMenuBars = 13;
  25.       MaxPull     = 8;
  26.  
  27. Type PullRec = Record
  28.       PullName   : Array [1..MaxPull] of String[20]; {naam pulldown menu}
  29.       PullEntry  : Array [1..MaxPull] of Longint;
  30.      End;
  31.      MenuStr = String[10];
  32.      SubStr  = String[25];
  33.  
  34. Var UpdateMenu    : Boolean; {When to refresh BG's menu}
  35.     UpdateSub     : Boolean;
  36.     SubMenuActive : Boolean; {Needed to filter out keystrokes}
  37.     (* Menu interface voor NG *)
  38.     MainMenuStr   : Array [1..MaxMenuBars] of MenuStr;{Standaard menus}
  39.     PullInfo      : Array [3..MaxMenuBars] of PullRec;
  40.     MainMenuCount : Byte; {Max 255 mainmenus}
  41.     MainMenuBar   : Byte; {Highlighted menu}
  42.     PullMenuBar   : Byte;
  43.     SeeAlsoBar    : Byte;
  44.     MainNum,
  45.     PullNum       : Byte; {Voor Tag}
  46.     DrawSub       : Boolean; {Draw the submenu from scratch}
  47.     SubMenu       : WindowOBJ;
  48.         (* Var voor het norton guide hulp gedeelte *)
  49.     Short         : Boolean;
  50.     GuideMenu     : GuideMenuOBJ;
  51.     GuideShort    : GuideShortOBJ;
  52.     GuideLong     : GuideLongOBJ;
  53.  
  54.     HTekst,STekst : Longint;
  55.  
  56.  
  57. Procedure NGHelpScreen;
  58. Var ExitCode : Char;
  59.     Loop     : Byte;
  60. Begin
  61.  With AskWindow Do
  62.   Begin
  63.    Init;
  64.    AddTitle(' About Help''s Norton Guide Cloon ');
  65.    AddLine(FillStr(Space,72));
  66.    AddLine('      <esc>  Back one level        <->  Show Previous long entry');
  67.    AddLine('      F9     Full/Half screen      <+>  Show Next long entry');
  68.    AddLine('^F10    Exit the guide');
  69.    AddLine('');
  70.    AddLine('^The Norton Guide Cloon incorporated in HELP');
  71.    AddLine('^Copyright 1991 by Yvo Nelemans');
  72.    AddLine('');
  73.  
  74.    For Loop := 1 to 5 Do AddLine('    '+Copy(Credit(Loop),1,70));
  75.    AddLine('');
  76.  
  77.    AddButton('Ok');
  78.    Go(ExitCode);
  79.    Done;
  80.   End;
  81. End;
  82.  
  83. Procedure ChangeColor(Color : Boolean);
  84. Begin
  85.  Default.Color := Color;
  86.  
  87.  if Not Color then
  88.   Begin {Maak Black/White}
  89.    WindowC_NG := LightGray+BlackBG;
  90.    WindowH_NG := Black+LightGrayBG;
  91.    MenuC_NG   := White+BlackBG;
  92.    BoldFase   := White+BlackBG;
  93.    UnderLine  := Green+BlackBG;
  94.    Reverse    := Black+LightGrayBG;
  95.   End Else Begin {Maak Color}
  96.             WindowC_NG := LightCyan+BlueBG;
  97.             WindowH_NG := Black+CyanBG;
  98.             MenuC_NG   := Yellow+BlueBG;
  99.             BoldFase   := Yellow+BlueBG;
  100.             UnderLine  := LightMagenta+BlueBG;
  101.             Reverse    := Black + CyanBG;
  102.            End;
  103. End;
  104.  
  105. Procedure ChangeWindowSize(Big : Boolean);
  106. Begin
  107.  X1_NG := 1; X2_NG := 80;
  108.  
  109.  Default.BigScreen := Big;
  110.  
  111.  if Not Big then
  112.   Begin
  113.    if YPosition>12 then
  114.     Begin
  115.      Y1_NG  :=  1;
  116.      Y2_NG  := Y1_NG+11;
  117.     End Else Begin
  118.               Y2_NG := MaxRows;
  119.               Y1_NG := Y2_NG-11;
  120.              End;
  121.   End Else Begin
  122.             Y1_NG  :=  1;
  123.             Y2_NG  := MaxRows;
  124.            End;
  125. End;
  126.  
  127. Procedure InitVars_NG;
  128. Begin
  129.  UpdateMenu    := False;
  130.  UpdateSub     := False;
  131.  SubMenuActive := False;
  132.  DrawSub       := True;
  133.  Short         := True;
  134.  
  135.  HTekst  := 1; STekst := 1;
  136.  MainNum := 0; PullNum := 0;
  137.  
  138.  ChangeColor(Default.Color);
  139. End;
  140.  
  141. Procedure FreeGuideMem;
  142. Begin
  143.  if NoGuide then Exit;
  144.  if Short then
  145.   With GuideShort Do Done
  146.   Else With GuideLong Do Done;
  147. End;
  148.  
  149. Procedure ClearMenuVars;
  150. Begin
  151.  MainMenuBar    := 1; {Start met 'Expand' highlighted}
  152.  MainMenuStr[1] := 'Expand';
  153.  MainMenuStr[2] := 'Search...';
  154.  MainMenuStr[3] := 'Options';
  155.  FillChar(PullInfo,Sizeof(PullInfo),#0);
  156.  PullInfo[3].PullName[1] := 'Database';
  157.  PullInfo[3].PullName[2] := 'Color';
  158.  PullInfo[3].PullName[3] := 'Full screen  F9';
  159.  PullInfo[3].PullName[4] := 'Auto lookup';
  160.  PullInfo[3].PullName[5] := 'Hot key';
  161.  PullInfo[3].PullName[6] := 'Uninstall';
  162.  PullInfo[3].PullName[7] := 'Save options';
  163. { PullInfo[3].PullName[8] := 'Go to THELP';}
  164.  MainMenuCount  := 3; {3 menus}
  165.  PullMenuBar    := 1;
  166. End;
  167.  
  168. Procedure SubInfo(Var Len,Depth : Byte);
  169. Var Loop : Byte;
  170. Begin
  171.  Len := Length(PullInfo[MainMenuBar].PullName[1]);
  172.  Depth := 0;
  173.  For Loop := 1 to MaxPull Do
  174.   Begin
  175.    if Length(PullInfo[MainMenuBar].PullName[Loop])>Len then
  176.     Len := Length(PullInfo[MainMenuBar].PullName[Loop]);
  177.    if Length(PullInfo[MainMenuBar].PullName[Loop])<>0 then Inc(Depth)
  178.   End;
  179. End;
  180.  
  181. Procedure ClearStatusLine;
  182. Begin
  183.  Screen.FastWrite(2,2,WindowC_NG,FillStr(Space,78));
  184. End;
  185.  
  186. Procedure WriteSubMenu;
  187. Var Len,Depth,
  188.     Loop,XPos : Byte;
  189.     St        : String[24];
  190. Begin
  191.  UpdateSub := False;
  192.  if (MainMenuBar=1) Or (MainMenuBar=2) then Exit;
  193.  
  194.  XPos := 3;
  195.  For Loop := 1 to Pred(MainMenuBar) Do
  196.   XPos := XPos + Length(MainMenuStr[Loop]) + 2;
  197.  SubInfo(Len,Depth);
  198.  
  199.  if DrawSub then
  200.   Begin
  201.    DrawSub := False;
  202.    With SubMenu Do
  203.     Begin
  204.      Init;
  205.      SetColor(WindowC_NG);
  206.      SetSize(Depth,Len+3,SingleBrdr);
  207.      if XPos+Len+4>79 then XPos := 79-(Len+4);
  208.      ShowWindow(XPos,Y1_NG+2);
  209.      With Screen Do
  210.       Begin
  211.        vWindowIgnore := True;
  212.        FastPWrite(XPos,Y1_NG+2,#194);
  213.        FastPWrite(XPos+Len+4,Y1_NG+2,#194);
  214.        vWindowIgnore := False;
  215.       End;
  216.     End;
  217.   End;
  218.  
  219.  For Loop := 1 to Depth Do With Screen Do
  220.   Begin
  221.    St := FillRight('  '+PullInfo[MainMenuBar].PullName[Loop],Len+3);
  222.    if MainMenuBar=3 then
  223.     Begin
  224.      if (Loop=2) And Default.Color then St[1] := #251;
  225.      if (Loop=4) And Default.AutoLookUp then St[1] := #251;
  226.     End;
  227.  
  228.    if (MainMenuBar=MainNum) And (Loop=PullNum) then St[1] := #251;
  229.    if Loop=PullMenuBar then
  230.     FastWrite(1,Loop,WindowH_NG,St)
  231.     Else FastWrite(1,Loop,MenuC_NG,St);
  232.   End
  233.  
  234. End;
  235.  
  236. Procedure WriteMenuBar;
  237. Var Loop,
  238.     XPos,
  239.     Color : Byte;
  240. Begin
  241.  if Not UpdateMenu then Exit;
  242.  UpdateMenu := False;
  243.  
  244.  XPos := 3;
  245.  With Screen Do
  246.   Begin
  247.    For Loop := 1 to MainMenuCount Do
  248.     Begin
  249.      if Loop=MainMenuBar then
  250.       FastWrite(XPos,2,WindowH_NG,Space+MainMenuStr[Loop]+Space)
  251.       Else FastWrite(XPos,2,MenuC_NG,Space+MainMenuStr[Loop]+Space);
  252.      XPos := XPos + Length(MainMenuStr[Loop]) + 2;
  253.     End;
  254.   End;
  255.  WriteSubMenu;
  256. End;
  257.  
  258. Procedure ClearBar;
  259. Begin
  260.  Screen.ChangeAttr(2,HTekst-STekst+4,WindowC_NG,78);
  261. End;
  262.  
  263. Procedure WriteBar;
  264. Begin
  265.  Screen.ChangeAttr(2,HTekst-STekst+4,WindowH_NG,78);
  266. End;
  267.  
  268. Procedure FillWord(Var Dest;Width,Value : Word;Var XPos : Byte);
  269. Begin
  270.  Inc(XPos,Width);
  271.  
  272.  if CheckSnow then
  273.   Inline($C4/$BE/Dest/            {         LES     DI,Dest[BP]       }
  274.          $8B/$8E/Width/           {         MOV     CX,Width[BP]      }
  275.          $8B/$9E/Value/           {         MOV     BX,Value[BP]      }
  276.          $FC/                     {         CLD                       }
  277.          $E3/$16/                 {         JCXZ    READY             }
  278.          $BA/$03DA/               {         MOV     DX,3DAH           }
  279.          $B4/$09/                 {         MOV     AH,9              }
  280.          $EC/                     { TEST1:  IN      AL,DX             }
  281.          $D0/$D8/                 {         RCR     AL,1              }
  282.          $72/$FB/                 {         JB      TEST1             }
  283.          $FA/                     {         CLI                       }
  284.          $EC/                     { TEST2:  IN      AL,DX             }
  285.          $22/$C4/                 {         AND     AL,AH             }
  286.          $74/$FB/                 {         JZ      TEST2             }
  287.          $8B/$C3/                 {         MOV     AX,BX             }
  288.          $AB/                     {         STOSW                     }
  289.          $FB/                     {         STI                       }
  290.          $E2/$EF) Else            {         LOOP    TEST1             }
  291.